var setupTask;
var reviveCount = 5;
var mapIds = [331001120, 331001130];
var 准备地图 = 331001110;
var eventName = "超能力者_教学";

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully()
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0))
}

function onMonsterKilled(a, b) {
    if (player.getMap().getNumMonsters() == 0) {
        if (player.getMapId() == 331001120 && player.getAPI().getNumberFromQuestInfo(22700, "kinetuto") == 0) {
            player.getAPI().updateInfoQuest(22700, "V01=1;V02=1;kinetuto=1;E1=1");
            player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100)
        } else {
            if (player.getMapId() == 331001130 && player.getAPI().getNumberFromQuestInfo(22700, "kinetuto2") == 0) {
                player.getAPI().updateInfoQuest(22700, "V01=1;V02=1;kinetuto=1;kinetuto2=1;E1=1;E2=1");
                player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear")
            } else {
                player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear")
            }
        }
    }
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
}

function Chuansong(b, a) {
    if (b.getMapInstance(331004100).getCharactersSize() != 0) {
        warp(b, 331004200, 0)
    } else {
        if (b.getMapInstance(331004200).getCharactersSize() != 0) {
            warp(b, 331004300, 0)
        } else {
            if (b.getMapInstance(331004300).getCharactersSize() != 0) {
                warp(b, 331004000, 0)
            } else {
                if (b.getMapInstance(331004000).getCharactersSize() != 0) {
                    warp(b, 331005400, 0)
                }
            }
        }
    }
}

function openNpc(c, b, d) {
    for (var a = 0; a < c.getPlayerCount(); a++) {
        c.getPlayers().get(a).getAPI().openNpc(b, d)
    }
}

function warp(d, c, a) {
    for (var b = 0; b < d.getPlayerCount(); b++) {
        d.getPlayers().get(b).getAPI().warp(c, a)
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function onPlayerRevived(b, a) {
    return false
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onMonsterDamaged(b, a, d, e, c) {}

function onItemPickedUp() {};